<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\callback\controller\tim;

/**
 * Description of Timcallback
 *
 * @author DevPHP
 * @version 2018-4-10
 */
class Timcallback {

    public function index() {
        // https://cloud.tencent.com/document/product/269/1619
        if (isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
            $json = $GLOBALS['HTTP_RAW_POST_DATA'];
        } else {
            $json = file_get_contents('php://input');
        }
        $post = json_decode($json, true);
        \think\facade\Log::info($json);
        if ($post['CallbackCommand'] == 'Group.CallbackBeforeSendMsg') {
            // 群组发言前回调
        } else if ($post['CallbackCommand'] == 'Group.CallbackAfterNewMemberJoin') {
            // 加入群组后回调
        } else if ($post['CallbackCommand'] == 'Group.CallbackAfterMemberExit') {
            // 离开群组后回调
        }

        $data = array('ActionStatus' => 'OK', 'ErrorCode' => 0, 'ErrorInfo' => '');
        return json_encode($data);
    }

}
